// https://ac.nowcoder.com/acm/problem/21302
#include<bits/stdc++.h>
#define _  ios_base::sync_with_stdio(0),cin.tie(0)
using namespace std;
const int mod=1e9+7;
int main()
{
	_; 
    string t;
    cin>>t;
    int len=t.length();
    int dp[55][3];
    memset(dp,0,sizeof(dp));
    int m=0;
    dp[0][(t[0]-'0')%3]=1;
    for(int i=1;i<len;i++)
	{
        m=(t[i]-'0')%3;
        dp[i][m]=(dp[i][m]+1)%mod;
        for(int j=0;j<3;j++)
		{
            dp[i][j]+=(dp[i-1][j]+dp[i-1][(j+3-m)%3])%mod;
        }
    }
    cout<<dp[len-1][0]%mod<<endl;
    return 0;
}
